{# vim: set et ts=8 sts=4 sw=4 ai: #}
{% extends "page.html" %}
{%block head %}
{{ super() }}
<meta name="robots" content="noindex, nofollow">
{% endblock %}
{% block extra_nav %}{% endblock %}
{% block content %}
<div class="w-full mw-full p-0 clearfix">
    <h2 class="float-left">Attachments</h2>
</div>
{# upload form #}
{% if has_permission("UPLOAD") %}
<div class="card m-0 p-1">
  <form action="{{ url_for("attachments" , pagepath=pagepath) }}" method="POST" class="form-inline" enctype=multipart/form-data>
  <div class="custom-file">
    <input name="file" type="file" id="file-upload" multiple="multiple">
    <label for="file-upload">Choose files to upload</label>
  </div>
  <div class="form-group">
      <input type="text" class="form-control" name="message" id="message" placeholder="Commit message" value="{{message}}">
  </div>
  <div class="form-group m-0">
    <input class="btn btn-primary" type="submit" value="Upload">
  </div>
  </form>
</div>
{% endif %}
{# file list #}
<div class="w-full mw-full my-15">
  <div class="table-striped">
    <table class="table">
      <thead>
        <tr>
          <th>Thumbail</th>
          <th>Filename</th>
          <th>Size</th>
          <th>Date</th>
          <th>Author</th>
          <th class="w-half">Comment</th>
{% if has_permission("READ") %}
          <th></th>
{% endif %}
        </tr>
      </thead>
      <tbody>
{% for f in files %}
        <tr class="align-top">
            <td><a href="{{f.url}}">{% if f.thumbnail_url %}<img src="{{f.thumbnail_url}}"/>{%else%}{{f.thumbnail_icon|safe}}{%endif%}</a></td>
            <td><a href="{{f.url}}">{{f.filename}}</a><br/>
            </td>
            <td>{{f.filesize}}
            <td>{{f.datetime|format_datetime}}<br/><span class="btn revision-small">{{f.revision}}</span></td>
            <td>{{f.author_name}}</td>
            <td>{{f.message}}</td>
{% if has_permission("READ") %}
            <td><a href="{{ url_for("edit_attachment", pagepath=pagepath, filename=f.filename) }}" class=""><i class="fas fa-edit"></i></a></td>
{% endif %}
        </tr>
{% endfor %}
      </tbody>
    </table>
  </div>
</div>
{% endblock %}
